package com.pgybook.db.entity.mapper;

import org.springframework.stereotype.Repository;
import com.pgybook.db.entity.domain.BackgroundJob;
import com.pgybook.db.entity.domain.BackgroundJobEx;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Repository
public interface BackgroundJobMapper {
    int countByExample(BackgroundJobEx example);

    int deleteByExample(BackgroundJobEx example);

    @Delete({
            "delete from backgroundjob",
            "where BACKGROUNDJOBID = #{backgroundjobid,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer backgroundjobid);

    @Insert({
            "insert into backgroundjob (TYPE, SUBTYPE, ",
            "OBJID, STARTTIME, ",
            "ENDTIMETIME, STATUS, ",
            "MEMO)",
            "values (#{type,jdbcType=INTEGER}, #{subtype,jdbcType=INTEGER}, ",
            "#{objid,jdbcType=BIGINT}, #{starttime,jdbcType=TIMESTAMP}, ",
            "#{endtimetime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER}, ",
            "#{memo,jdbcType=VARCHAR})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "backgroundjobid", before = false, resultType = Integer.class)
    int insert(BackgroundJob record);

    int insertSelective(BackgroundJob record);

    List<BackgroundJob> selectByExample(BackgroundJobEx example);

    @Select({
            "select",
            "BACKGROUNDJOBID, TYPE, SUBTYPE, OBJID, STARTTIME, ENDTIMETIME, STATUS, MEMO",
            "from backgroundjob",
            "where BACKGROUNDJOBID = #{backgroundjobid,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    BackgroundJob selectByPrimaryKey(Integer backgroundjobid);

    int updateByExampleSelective(@Param("record") BackgroundJob record, @Param("example") BackgroundJobEx example);

    int updateByExample(@Param("record") BackgroundJob record, @Param("example") BackgroundJobEx example);

    int updateByPrimaryKeySelective(BackgroundJob record);

    @Update({
            "update backgroundjob",
            "set TYPE = #{type,jdbcType=INTEGER},",
            "SUBTYPE = #{subtype,jdbcType=INTEGER},",
            "OBJID = #{objid,jdbcType=BIGINT},",
            "STARTTIME = #{starttime,jdbcType=TIMESTAMP},",
            "ENDTIMETIME = #{endtimetime,jdbcType=TIMESTAMP},",
            "STATUS = #{status,jdbcType=INTEGER},",
            "MEMO = #{memo,jdbcType=VARCHAR}",
            "where BACKGROUNDJOBID = #{backgroundjobid,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(BackgroundJob record);
}
